import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2024-01-09
 * Time: 17:05
 */
public class mymstack {
    Stack<Integer> zhan;
    Stack<Integer> minzhan;
    public mymstack() {
        zhan=new Stack<>();
        minzhan =new Stack<>();
    }

    public void push(int val) {
        zhan.push(val);
        if(minzhan.empty()){
            minzhan.push(val);
        }else{
            if(val<=minzhan.peek()){
                minzhan.push(val);
            }
        }
    }

    public void pop() {
        if(zhan.empty()){
            return;
        }
        if(zhan.peek().equals(minzhan.peek())){
            minzhan.pop();
        }
        zhan.pop();
    }

    public int top() {

        return zhan.peek();

    }

    public int getMin() {
        return minzhan.peek();
    }
}